********************************************************************
*** Example of calculating average effects across time with -sdpe-
***
*** Created: 2-17-16
*** Modified: 3-6-18
***
*** NOTE: a few of the subcommands rely *heavily* on -simqi- and -setx- from King, Tomz and Wittenberg's clarify program.  Make sure to install this on your computer before running -sdpe-.
********************************************************************

*** Set working directory
* cd ""

*** Run the file containing the -sdpe- command
* do ""

*** Load the data
use "Dyad.dta", clear

*** In-sample partial effects
quietly logit dispute dem_low dem_hi growth_low allies contig capratio /*
*/	depend_low d_depend_hi democ_chg autoc_chg _prefail t t2 t3
sdpe dem_low -10 10
return list

*** In-sample partial effects across t (minimum, maximum, mean and standard deviation)
sdpe dem_low -10 10, comp(t)
return list

*** Graph out the mean and standard deviation across t
preserve
	clear
	matrix tempcond = r(tempcond)
	svmat tempcond, names(col)
	twoway (line mean_pe t) (line sd_pe t, lpattern(dash)), /*
	*/	ytitle("Partial Effect") legend(label(1 "Mean") label(2 "S.D."))
restore
